import DashboardUtil from "@/visual/commons/utils/dashboard-util";
import type DashboardComponentType from "@/visual/commons/types/dashboard-component-type";


/**
 * 分组样式生成器
 */
export default class GroupStyleGenerator {
    static containerStyleGenerator(comp: DashboardComponentType<any>): Object {
        let transform = '';
        if (comp.styleProps && comp.styleProps.transformRotate) {
            transform += ` rotate(${comp.styleProps?.transformRotate}deg)`
        }

        if (comp.styleProps && comp.styleProps.transformScale) {
            transform += ' ' + DashboardUtil.geetTransformScaleCssVal(comp.styleProps?.transformScale);
        }

        return {
            transform,
        };
    }

    static componentStyleGenerator(comp: DashboardComponentType<any>): Object {

        return {
            borderTopColor: comp.styleProps?.borderTop?.color,
            borderTopWidth: comp.styleProps?.borderTop?.width + "px",
            borderTopStyle: comp.styleProps?.borderTop?.style,
            borderBottomColor: comp.styleProps?.borderBottom?.color,
            borderBottomWidth: comp.styleProps?.borderBottom?.width + "px",
            borderBottomStyle: comp.styleProps?.borderBottom?.style,
            borderLeftColor: comp.styleProps?.borderLeft?.color,
            borderLeftWidth: comp.styleProps?.borderLeft?.width + "px",
            borderLeftStyle: comp.styleProps?.borderLeft?.style,
            borderRightColor: comp.styleProps?.borderRight?.color,
            borderRightWidth: comp.styleProps?.borderRight?.width + "px",
            borderRightStyle: comp.styleProps?.borderRight?.style,
            backgroundColor: comp.styleProps?.backgroundColor,
            backgroundImage: comp.styleProps?.backgroundImage
                ? `url(${comp.styleProps?.backgroundImage})`
                : "",
            backgroundRepeat: comp.styleProps?.backgroundRepeat,
            backgroundSize:
                comp.styleProps?.backgroundSize &&
                    comp.styleProps?.backgroundSize.length > 1
                    ? `${comp.styleProps?.backgroundSize[0]}  ${comp.styleProps?.backgroundSize[1]}`
                    : "",
            backgroundPosition:
                comp.styleProps?.backgroundPosition &&
                    comp.styleProps?.backgroundPosition.length > 1
                    ? `${comp.styleProps?.backgroundPosition[0]}  ${comp.styleProps?.backgroundPosition[1]}`
                    : "",
        };
    }


}